﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.IO;
namespace DAL.Simulation
{
    public class ImageItem
    {
        public string ThumbnailClientId { get; set; }
        public string ThumbnailValue { get { return Value; } }
        public string Url { get; set; }
        public string Title { get; set; }
        public string Value { get; set; }
    }

    public class MyImages
    {
        public ICollection GetImagesFromFileSystem(string folderName, bool setThumbnails)
        {
            DirectoryInfo di = new DirectoryInfo(Context.Server.MapPath(folderName));
            List<ImageItem> imageItemList = null;
            if (di.Exists)
            {
                FileInfo[] files = di.GetFiles();
                if (files.Length == 0) return null;
                imageItemList = new List<ImageItem>(files.Length);
                foreach (FileInfo file in files)
                {
                    ImageItem item = new ImageItem();
                    item.Url = VirtualPathUtility.ToAbsolute(string.Format(@"{0}{1}", folderName, file.Name));
                    item.Title = Path.GetFileNameWithoutExtension(file.FullName);
                    item.Value = file.Name;
                    if (setThumbnails)
                        item.ThumbnailClientId = file.Name;
                        imageItemList.Add(item);
                }
            }
            return imageItemList;
        }
        public void UpdateImages()
        {
            throw new NotImplementedException();
        }
        public void InsertImages()
        {
            throw new NotImplementedException();
        }
        public void DeleteImages()
        {
            throw new NotImplementedException();
        }
        public MyImages(HttpContext context)
        {
            Context = context;
        }
        public MyImages()
        {
            Context = HttpContext.Current;
        }
        public HttpContext Context { get; set; }
    }
}